import { mapState, mapActions } from "vuex";
import { baseFileds } from "../options";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState("options", ["personListGroup"]),
    fileds() {
      return baseFileds(
        this.type === "detail" ? "detail" : "add",
        this.formData.publishScope,
        this.personListGroup,
        this.receiptStatus
      );
    },
    subFileds() {
      return [
        {
          key: "businessStatus",
          filedType: "Radio",
          label: "选择路径",
          span: 24,
          props: {
            disabled: this.type === "detail",
            options: [
              { value: "UNDO", label: "送审" },
              { value: "DONE", label: "发布信息" },
            ],
            rules: [
              { required: true, message: "请选择路径", trigger: "change" },
            ],
          },
        },
        {
          key: "auditorIds",
          filedType: "Cascader",
          label: "添加审批人",
          span: 24,
          hidden: this.formData.businessStatus !== "UNDO",
          props: {
            options: this.personListGroup,
            filterable: true,
            showAllLevels: false,
            disabled: this.type === "detail",
            props: {
              multiple: true,
              value: "personId",
              label: "name",
              children: "cimContactsVOList",
            },
            rules: [
              {
                validator: (rule, value, callback) => {
                  if (this.formData.businessStatus === "UNDO") {
                    if (value.length <= 0) {
                      callback(new Error("请选择审批人"));
                    }
                  }
                  callback();
                },
              },
            ],
          },
        },
      ];
    },
  },
  created() {
    this.getPersonGroup();
  },
  methods: {
    ...mapActions("options", ["getPersonGroup"]),
  },
};
